<template>
  <div class="input-wrapper" :class="{ active: isActive }">
    <label>{{ label }}</label>
    <input
      @input="$emit('update:modelValue', $event.target.value)"
      @focus="isActive = true"
      @blur="isActive = false"
      :type="type"
    />
    <aside>{{ warning }}</aside>
  </div>
</template>

<script>
import { ref } from "vue";
export default {
  props: {
    label: String,
    type: String,
    warning: String,
  },
  setup() {
    const isActive = ref(false);
    return {
      isActive,
    };
  },
};
</script>

<style lang="scss" scoped>
.input-wrapper {
  position: relative;
  display: flex;
  justify-content: center;
  font-size: 1.075rem;
  line-height: 2em;
  border: 1px solid rgba(128, 128, 128, 0.4);
  height: 2em;
  margin: 1em;
  label {
    // width: 3.5em;
    color: rgba(0, 0, 0, 0.8);
    padding: 0 0.5em;
    background: rgb(233, 233, 233);
  }
  input {
    border: none;
    outline: none;
    padding-left: 0.5em;
    flex: 1;
    width: 100%;
    font-size: inherit;
  }
  aside {
    position: absolute;
    top: calc(100% - 0.8em);
    left: 0;
    width: 100%;
    text-align: center;
    color: red;
    font-size: 0.5em;
    text-overflow: ellipsis;
  }
}
.active {
  box-shadow: 0 2px 5px rgba(75, 75, 74, 0.8);
}
.input-wrapper:hover {
  border: 1px solid rgba(23, 123, 218, 0.4);
  box-shadow: 0 0 5px rgba(75, 75, 74, 0.8);
}
</style>